home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / misc / fancybox.sty (.txt) < prev    next >
LaTeX Document  |  1993-02-16  |  70KB  |  1,883 lines

  1. %% BEGIN fancybox.sty
  2. \def\fileversion{1.0}
  3. \def\filedate{93/02/10}
  4. %% COPYRIGHT 1993, by Timothy Van Zandt, tvz@Princeton.EDU
  5. %% DESCRIPTION:
  6. %%   fancybox.sty is a LaTeX style option, consisting of:
  7. %%   * Variants of \fbox: \shadowbox, \doublebox, \ovalbox, \Ovalbox.
  8. %%   * Helpful tools for using box macros.
  9. %%   * Extensive documentation about how to use box macros.
  10. %%   * Flexible verbatim macros.
  11. %% INSTALLATION:
  12. %%   Put this file where your TeX looks for inputs.
  13. %% DOCUMENTATION:
  14. %%  See fancybox.doc, which might be appended to this file.
  15. %% COPYING:
  16. %%   Copying of part or all of this file is allowed under the following
  17. %%   conditions only:
  18. %%   (1) You may freely distribute unchanged copies of the file. Please
  19. %%       include the documentation when you do so.
  20. %%   (2) You may modify a renamed copy of the file, but only for personal
  21. %%       use or use within an organization.
  22. %%   (3) You may copy fragments from the file, for personal use or for
  23. %%       distribution, as long as credit is given where credit is due.
  24. %%   You are NOT ALLOWED to take money for the distribution or use of
  25. %%   this file or modified versions or fragments thereof, except for
  26. %%   a nominal charge for copying etc.
  27. %% CODE:
  28. \expandafter\ifx\csname fb@framepage\endcsname\relax\else
  29.   \expandafter\endinput
  30. \typeout{Style option: `fancybox' v\fileversion \space  <\filedate> (tvz)}
  31. \newbox\@fancybox
  32. \@ifundefined{@tempdimc}{\newdimen\@tempdimc}{}
  33. %% \shadowbox
  34. \newdimen\shadowsize
  35. \shadowsize 4pt
  36. \def\shadowbox{\VerbBox\@shadowbox}
  37. \def\@shadowbox#1{%
  38.   \setbox\@fancybox\hbox{\fbox{#1}}%
  39.   \leavevmode\vbox{%
  40.     \offinterlineskip
  41.     \dimen@=\shadowsize
  42.     \advance\dimen@ .5\fboxrule
  43.     \hbox{\copy\@fancybox\kern-.5\fboxrule\lower\shadowsize\hbox{%
  44.       \vrule \@height\ht\@fancybox \@depth\dp\@fancybox \@width\dimen@}}%
  45.     \vskip-\dimen@
  46.     \moveright\shadowsize\vbox{%
  47.       \hrule \@width\wd\@fancybox \@height\dimen@}}}
  48. % \fancyoval
  49. \def\cornersize{\@ifstar{\@cornersize}{\@@cornersize}}
  50. \def\@cornersize#1{%
  51.   \@tempdima=#1\relax
  52.   \edef\the@cornersize{\number\@tempdima sp}}
  53. \def\@@cornersize#1{%
  54.   \edef\the@cornersize{#1\noexpand\@tempdimb}}
  55. \cornersize{.5}
  56. % This is just a simple change to \oval, making use of the \cornersize
  57. % parameter instead of making the corner arcs are large as possible.
  58. \def\fancyoval(#1,#2){\@ifnextchar[{\fancy@oval(#1,#2)}{\fancy@oval(#1,#2)[]}}
  59. \def\fancy@oval(#1,#2)[#3]{%
  60.   \begingroup
  61.     \fancy@@oval{#1\unitlength}{#2\unitlength}{#3}%
  62.     \@put{-.5\wd\@tempboxa}{-.5\ht\@tempboxa}{\ht\@tempboxa=\z@\box\@tempboxa}%
  63.   \endgroup}
  64. \def\fancy@@oval#1#2#3{%
  65.   \boxmaxdepth \maxdimen
  66.   \@ovttrue \@ovbtrue \@ovltrue \@ovrtrue
  67.   \@tfor\@tempa :=#3\do{\csname @ov\@tempa false\endcsname}%
  68.   \@ovxx#1\relax
  69.   \advance\@ovxx-\@wholewidth
  70.   \@ovyy#2\relax
  71.   \advance\@ovyy-\@wholewidth
  72.   \@tempdimb \ifdim \@ovyy >\@ovxx \@ovxx\else \@ovyy \fi
  73.   \advance\@tempdimb-2\p@
  74.   \ifdim\@tempdimb>\the@cornersize\relax
  75.     \@tempdimb=\the@cornersize
  76.   \fi
  77.   \@getcirc\@tempdimb
  78.   \@ovro\ht\@tempboxa \@ovri\dp\@tempboxa
  79.   \@ovdx\@ovxx \advance\@ovdx-\@tempdima \divide\@ovdx \tw@
  80.   \@ovdy\@ovyy \advance\@ovdy-\@tempdima \divide\@ovdy \tw@
  81.   \@circlefnt
  82.   \setbox\@tempboxa\hbox{%
  83.     \if@ovr \@ovvert32\kern -\@tempdima \fi
  84.     \if@ovl \kern \@ovxx \@ovvert01\kern -\@tempdima \kern -\@ovxx \fi
  85.     \if@ovt \@ovhorz \kern -\@ovxx \fi
  86.     \if@ovb \raise \@ovyy \@ovhorz \fi}%
  87.   \advance\@ovdx\@ovro
  88.   \advance\@ovdy\@ovro
  89.   \advance\@ovxx\@wholewidth
  90.   \wd\@tempboxa=\@ovxx
  91.   \dp\@tempboxa=\z@}
  92. % \ovalbox
  93. \def\ovalbox{\VerbBox{\@ovalbox\thinlines}}
  94. \def\Ovalbox{\VerbBox{\@ovalbox\thicklines}}
  95. \def\@ovalbox#1#2{%
  96.   \begingroup
  97.     #1\relax
  98.     \setbox\@fancybox\hbox{{#2}}%
  99.     \@tempdimc\fboxsep \advance\@tempdimc\@wholewidth
  100.     \@tempdima\ht\@fancybox \advance\@tempdima\dp\@fancybox
  101.     \advance\@tempdima2\@tempdimc
  102.     \@tempdimb\wd\@fancybox \advance\@tempdimb2\@tempdimc
  103.     \fancy@@oval\@tempdimb\@tempdima{}%
  104.     \@tempdima\dp\@fancybox \advance\@tempdima\@tempdimc
  105.     \wd\@tempboxa=\z@
  106.     \leavevmode\hbox{%
  107.       \lower\@tempdima\box\@tempboxa
  108.       \kern\@tempdimc\box\@fancybox\kern\@tempdimc}%
  109.   \endgroup}
  110. % \doublebox
  111. \def\doublebox{\VerbBox\@doublebox}
  112. \def\@doublebox#1{%
  113.   \begingroup
  114.     \setbox\@fancybox\hbox{{#1}}%
  115.     \fboxrule=.75\fboxrule
  116.     \setbox\@fancybox\hbox{\fbox{\box\@fancybox}}%
  117.     \fboxrule=2\fboxrule
  118.     \fboxsep=\fboxrule
  119.     \advance\fboxsep .5pt
  120.     \fbox{\box\@fancybox}%
  121.   \endgroup}
  122. % Frames for seminar.sty:
  123. \@ifundefined{newslideframe}{}{%
  124.   \newslideframe{shadow}{\shadowbox{#1}}
  125.   \newslideframe{double}{\doublebox{#1}}
  126.   \newslideframe{oval}{\ovalbox{#1}}
  127.   \newslideframe{Oval}{\Ovalbox{#1}}}
  128. % Sbox environment
  129. \newbox\@Sbox
  130. \def\Sbox{\global\setbox\@Sbox\hbox\bgroup\ignorespaces}
  131. \def\endSbox{%
  132.   \@testtrue\ifhmode\ifinner\@testfalse\fi\fi
  133.   \if@test\@latexerr{Misplaced \string\endSbox! Should be in LR mode}\@ehd\fi
  134.   \egroup}
  135. \def\TheSbox{%
  136.   \ifvoid\@Sbox
  137.     \@latexerr{\string\TheSbox\space is empty!}\@ehd
  138.   \else
  139.     \box\@Sbox
  140.   \fi}
  141. \def\beginsbox#1{\setbox#1\hbox\bgroup\ignorespaces}
  142. \def\endsbox{\endSbox}
  143. % \VerbBox
  144. \newtoks\do@VerbBox
  145. \def\VerbBox#1{%
  146.   \do@VerbBox{#1}%
  147.   \afterassignment\begin@VerbBox
  148.   \setbox\@fancybox=\hbox}
  149. \def\begin@VerbBox{\aftergroup\end@VerbBox}
  150. \def\end@VerbBox{\the\do@VerbBox{\box\@fancybox}}%
  151. % \Btrivlist
  152. \def\@Blistrestore{%
  153.   \let\par\relax
  154.   \let\-\@dischyph \let\'\@acci \let\`\@accii \let\=\@acciii
  155.   \lineskip\normallineskip \baselineskip\normalbaselineskip}
  156. \def\Btrivlist#1{\@ifnextchar[{\@Btrivlist{#1}}{\@Btrivlist{#1}[]}}
  157. \def\@Btrivlist#1[#2]{%
  158.   \@Blistrestore
  159.   \let\\=\@Btrivlistcr
  160.   \fb@beginvbox{#2}%
  161.   \halign\bgroup
  162.     \if#1l\else\@empty\hfil\fi
  163.     \ignorespaces##\unskip
  164.     \if#1r\@empty\else\hfil\fi\cr}
  165. \def\endBtrivlist{\crcr\egroup\egroup\if@pboxsw$\fi}
  166. \def\fb@beginvbox#1{%
  167.   \leavevmode
  168.   \@pboxswfalse
  169.   \if#1b\@empty\vbox\else\if#1t\@empty\vtop\else
  170.     \ifmmode\vcenter\else\@pboxswtrue$\vcenter\fi
  171.   \fi\fi\bgroup}
  172. \def\@Btrivlistcr{\@ifstar
  173.   {\@ifnextchar[{@@Btrivlistcr}{\cr}}{\@ifnextchar[{\@@Btrivlistcr}{\cr}}}
  174. \def\@@Btrivlistcr[#1]{\cr\noalign{\vskip #1}}
  175. \def\Bcenter{\Btrivlist{c}}
  176. \def\endBcenter{\endBtrivlist}
  177. \def\Bflushleft{\Btrivlist{l}}
  178. \def\endBflushleft{\endBtrivlist}
  179. \def\Bflushright{\Btrivlist{r}}
  180. \def\endBflushright{\endBtrivlist}
  181. % \Blist
  182. \def\Blist#1#2{\@ifnextchar[{\@Blist{#1}{#2}}{\@Blist{#1}{#2}[]}}
  183. \def\@Blist#1#2[#3]{%
  184.   \ifnum\@listdepth>5
  185.     \@toodeep
  186.   \else
  187.     \global\advance\@listdepth\@ne
  188.   \fi
  189.   \itemindent\z@
  190.   \csname @list\romannumeral\the\@listdepth\endcsname
  191.   \def\@itemlabel{#1}%
  192.   \let\makelabel\@mklab
  193.   \@nmbrlistfalse
  194.   \@Blistrestore
  195.   \let\\=\@Blistcr
  196.   \let\item\Bitem
  197.   \@Bitemswfalse
  198.   #2\relax
  199.   \fb@beginvbox{#3}%
  200.   \halign\bgroup
  201.     \ignorespaces##&\hskip\labelsep\ignorespaces##\unskip\hfil\cr}
  202. \def\endBlist{\endBtrivlist\global\advance\@listdepth\m@ne}
  203. \newif\if@Bitemsw
  204. \def\Bitem{\@ifnextchar({\@Bitemcr\Bitem@skip}{\@Bitemcr\@Bitem}}
  205. \def\@Bitemcr{%
  206.   \if@Bitemsw
  207.     \def\next{\cr\noalign{\vskip\itemsep}}%
  208.   \else
  209.     \def\next{\global\@Bitemswtrue}%
  210.   \fi
  211.   \next}
  212. \def\Bitem@skip(#1){\noalign{\vskip #1}\@Bitem}
  213. \def\@Bitem{\@ifnextchar[{\Bitem@label}{\Bitem@nolabel}}
  214. \def\Bitem@label[#1]{\makelabel{#1}&}
  215. \def\Bitem@nolabel{%
  216.   \if@nmbrlist
  217.     \expandafter\advance\csname c@\@listctr\endcsname1 \fi
  218.   \makelabel{\@itemlabel}%
  219.   \if@nmbrlist\refstepcounter{\@listctr}\fi}
  220. \def\@Blistcr{\@ifstar
  221.   {\@ifnextchar[{@@Blistcr}{\cr&}}{\@ifnextchar[{\@@Blistcr}{\cr&}}}
  222. \def\@@Blistcr[#1]{\cr\noalign{\vskip #1}&}
  223. % \Bitemize
  224. \def\Bitemize{%
  225.   \ifnum\@itemdepth>3
  226.     \@toodeep
  227.   \else
  228.     \advance\@itemdepth\@ne
  229.   \fi
  230.   \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
  231.   \Blist{\csname\@itemitem\endcsname}{\def\makelabel####1{\hfil####1}}}
  232. \def\endBitemize{\endBlist}
  233. % \Bdescription
  234. \def\Bdescription{\Blist{}{\def\makelabel####1{\bf####1\hfil}}}
  235. \def\endBdescription{\endBlist}
  236. % \Benumerate
  237. \def\Benumerate{%
  238.   \ifnum\@enumdepth>3
  239.     \@toodeep
  240.   \else
  241.     \advance\@enumdepth\@ne
  242.   \fi
  243.   \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
  244.   \Blist{\csname label\@enumctr\endcsname}%
  245.     {\usecounter{\@enumctr}\def\makelabel####1{\hfil####1}}}
  246. \def\endBenumerate{\endBlist}
  247. % Beqnarray
  248. \def\Beqnarray{%
  249.   \stepcounter{equation}%
  250.   \let\@currentlabel\theequation
  251.   \def\@eqnnum{{\csname reset@font\endcsname\rm (\theequation)}}%
  252.   \global\@eqnswtrue\m@th
  253.   \global\@eqcnt\z@
  254.   \tabskip\@centering
  255.   \let\\\@eqncr
  256.   \vbox\bgroup
  257.     \halign\bgroup
  258.       \@eqnsel
  259.         \hskip\@centering
  260.         $\displaystyle\tabskip\z@{##}$%
  261.       &\global\@eqcnt\@ne
  262.         \hskip 2\arraycolsep
  263.         \hfil${##}$\hfil
  264.       &\global\@eqcnt\tw@
  265.         \hskip 2\arraycolsep
  266.         $\displaystyle\tabskip\z@{##}$%
  267.         \hfil
  268.         \tabskip\@centering
  269.       &\if@eqnsw\hskip 1em\fi
  270.         \hfil{##}\tabskip\z@
  271.       \cr}
  272. \def\endBeqnarray{%
  273.   \@@eqncr
  274.   \egroup
  275.   \global\advance\c@equation\m@ne
  276.   \egroup
  277.   \global\@ignoretrue}
  278. \@namedef{Beqnarray*}{\def\@eqncr{\nonumber\@seqncr}\Beqnarray}
  279. \@namedef{endBeqnarray*}{\nonumber\endBeqnarray}
  280. % \fb@outputage
  281. % Here we insert various hooks for rotating or framing the page.
  282. % Otherwise, it is the usual \@outputpage
  283. \def\fb@outputpage{%
  284.   \begingroup
  285.     \catcode`\ =10
  286.     \let\-\@dischyph
  287.     \let\'\@acci
  288.     \let\`\@accii
  289.     \let\=\@acciii
  290.     \if@specialpage
  291.       \global\@specialpagefalse\@nameuse{ps@\@specialstyle}%
  292.     \fi
  293.     \if@twoside
  294.       \ifodd\count\z@
  295.         \let\@thehead\@oddhead
  296.         \let\@thefoot\@oddfoot
  297.         \let\@themargin\oddsidemargin
  298.       \else
  299.         \let\@thehead\@evenhead
  300.         \let\@thefoot\@evenfoot
  301.         \let\@themargin\evensidemargin
  302.       \fi
  303.     \fi
  304.     \csname reset@font\endcsname
  305.     \normalsize
  306.     \baselineskip\z@
  307.     \lineskip\z@
  308.     \let\par\@@par
  309.     \ifx\this@fancypage\@empty\else
  310.       \this@fancypage
  311.       \gdef\this@fancypage{}%
  312.     \fi
  313.     \ifx\the@fancypage\@empty\else
  314.       \setbox\@outputbox\hbox{\the@fancypage{\box\@outputbox}}%
  315.     \fi
  316.     \ifx\fb@@rotatepage\@empty\else
  317.       \setbox\@outputbox\hbox{\fb@@rotatepage{\box\@outputbox}}%
  318.     \fi
  319.     \setbox\@outputbox\vbox{%
  320.       \@tempdima=\wd\@outputbox
  321.       \setbox\@tempboxa=\hbox to\@tempdima{%
  322.         \let\label\@gobble
  323.         \let\index\@gobble
  324.         \let\glossary\@gobble
  325.         \@thehead}%
  326.       \ht\@tempboxa\headheight
  327.       \dp\@tempboxa\z@
  328.       \box\@tempboxa
  329.       \vskip\headsep
  330.       \box\@outputbox
  331.       \baselineskip\footskip
  332.       \hbox to\@tempdima{%
  333.         \let\label\@gobble
  334.         \let\index\@gobble
  335.         \let\glossary\@gobble
  336.         \@thefoot}}
  337.     \ifx\the@@fancypage\@empty\else
  338.       \setbox\@outputbox\hbox{\the@@fancypage{\box\@outputbox}}%
  339.     \fi
  340.     \setbox\@outputbox\vbox{%
  341.       \ifnum\fancyput@flag>-1 \do@fancyput\fi
  342.       \vskip\topmargin
  343.       \moveright\@themargin\box\@outputbox}%
  344.     \ifx\fb@rotatepage\@empty\else
  345.        \setbox\@outputbox\hbox{\lower\ht\@outputbox\box\@outputbox}%
  346.        \dp\@outputbox\z@
  347.        \wd\@outputbox\z@
  348.        \setbox\@outputbox\hbox{\fb@rotatepage{\box\@outputbox}}%
  349.        \expandafter\fb@setoffsets\fb@theoffsets
  350.     \fi
  351.     \shipout\box\@outputbox
  352.     \global\@colht\textheight
  353.   \endgroup
  354.   \stepcounter{page}%
  355.   \let\firstmark\botmark}
  356. % \fancypage
  357. \def\the@fancypage{}
  358. \def\the@@fancypage{}
  359. \def\this@fancypage{}
  360. \def\fancypage#1#2{%
  361.   \def\the@fancypage{#1}%
  362.   \def\the@@fancypage{#2}%
  363.   \def\@outputpage{\fb@outputpage}}
  364. \def\thisfancypage#1#2{%
  365.   \gdef\@outputpage{\fb@outputpage}%
  366.   \gdef\this@fancypage{\def\the@fancypage{#1}\def\the@@fancypage{#2}}}
  367. % \fancyput
  368. % Token registers used to make it easier to put definitions in argument.
  369. % Boxes not processed until output so that contents can depend, e.g., on
  370. % current page or marks or whatever. This makes everything slightly more
  371. % complicated than one would expect.
  372. \newtoks\the@fancyput
  373. \newtoks\this@fancyput
  374. \def\fancyput@flag{-1}%
  375. % \fancyput@flag=-1 if no fancyput, 0 if regular fancyput, 1 if thisfancyput.
  376. \def\fancyput{%
  377.   \def\@outputpage{\fb@outputpage}
  378.   \@ifstar{\@testtrue\@fancyput}{\@testfalse\@fancyput}}
  379. \def\@fancyput{\@ifnextchar({\@@fancyput}{\@@fancyput(\z@,\z@)}}
  380. \def\@@fancyput(#1,#2)#3{%
  381.   \if@test
  382.     \expandafter\the@fancyput\expandafter{\the\the@fancyput\do{#1}{#2}{#3}}%
  383.   \else
  384.     \the@fancyput{\do{#1}{#2}{#3}}%
  385.   \fi
  386.   \gdef\fancyput@flag{\z@}}
  387. \def\thisfancyput{%
  388.   \gdef\@outputpage{\fb@outputpage}
  389.   \@ifstar{\@testtrue\@thisfancyput}{\@testfalse\@thisfancyput}}
  390. \def\@thisfancyput{\@ifnextchar({\@@thisfancyput}{\@@thisfancyput(\z@,\z@)}}
  391. \def\@@thisfancyput(#1,#2)#3{%
  392.   \if@test
  393.     \ifnum\fancyput@flag=\z@
  394.       \expandafter\global\expandafter\this@fancyput\expandafter{%
  395.         \the\this@fancyput\do{#1}{#2}{#3}}%
  396.     \else
  397.       \expandafter\global\expandafter\this@fancyput\expandafter{%
  398.         \the\the@fancyput\do{#1}{#2}{#3}}%
  399.     \fi
  400.   \else
  401.     \global\this@fancyput{\do{#1}{#2}{#3}}%
  402.   \fi
  403.   \gdef\fancyput@flag{1}}
  404. \def\do@fancyput{%
  405.   \def\do##1##2##3{\raise##2\hbox to\z@{\kern##1\relax##3\hss}}%
  406.   \setbox\@tempboxa=\hbox to\z@{%
  407.     \kern-\hoffset
  408.     \raise\voffset\hbox{%
  409.       \ifnum\fancyput@flag=\z@\the\the@fancyput\else\the\this@fancyput\fi}%
  410.     \hss}%
  411.   \ht\@tempboxa=\z@ \dp\@tempboxa=\z@
  412.   \box\@tempboxa
  413.   \gdef\fancyput@flag{\z@}%
  414.   \global\this@fancyput{}}
  415. % \Landscape
  416. \def\UsePageParameters{%
  417.   \clearpage
  418.   \global\@colht\textheight
  419.   \onecolumn}
  420. \def\fb@rotatepage{}
  421. \def\Landscape{\@ifstar{\@testtrue\@Landscape}{\@testfalse\@Landscape}}
  422. \def\@Landscape#1#2#3{%
  423.   \clearpage
  424.   \def\fb@rotatepage{#3}%
  425.   \def\@outputpage{\fb@outputpage}%
  426.   \@tempdima#1\relax
  427.   \@tempdimb#2\relax
  428.   \if@test
  429.     \edef\fb@theoffsets{{\voffset}{\hoffset}{\number\@tempdima sp}}%
  430.   \else
  431.     \edef\fb@theoffsets{{\hoffset}{\voffset}{\number\@tempdimb sp}}%
  432.   \fi
  433.   \advance\@tempdimb-\@tempdima
  434.   \advance\textwidth\@tempdimb
  435.   \advance\textheight-\@tempdimb
  436.   \UsePageParameters}
  437. \def\endLandscape{\clearpage\aftergroup\UsePageParameters}
  438. \def\fb@setoffsets#1#2#3{%
  439.   \@tempdima#1%
  440.   \advance#1#2%
  441.   #2#3
  442.   \advance#2-2in
  443.   \advance#2-\@tempdima}
  444. \@namedef{Landscape*}{\@testtrue\@Landscape}
  445. \@namedef{endLandscape*}{\endLandscape}
  446. % \LandScape
  447. \def\fb@@rotatepage{}
  448. \def\LandScape#1{%
  449.   \clearpage
  450.   \def\fb@@rotatepage{#1}%
  451.   \def\@outputpage{\fb@outputpage}%
  452.   \@tempdima\textheight
  453.   \textheight\textwidth
  454.   \textwidth\@tempdima
  455.   \UsePageParameters}
  456. \def\endLandScape{\clearpage\aftergroup\UsePageParameters}
  457. % \GenericCaption
  458. \def\GenericCaption#1{%
  459.   \par
  460.   \begingroup
  461.     \@parboxrestore
  462.     \normalsize
  463.     \vskip 10\p@
  464.     \setbox\@tempboxa\hbox{#1}%
  465.     \ifdim\wd\@tempboxa>\hsize
  466.       #1\par
  467.     \else
  468.       \hbox to\hsize{\hfil\box\@tempboxa\hfil}%
  469.     \fi
  470.   \endgroup
  471.   \par}
  472. % \landfloat
  473. \def\landfloat#1#2{%
  474.   \gdef\curr@landfloat{#1}%
  475.   \gdef\float@rotation{#2}%
  476.   \begin{#1}[p]%
  477.     \setbox\@tempboxa\vbox\bgroup
  478.       \hsize\@colht
  479.       \@parboxrestore}
  480. \def\endlandfloat{%
  481.       \par\vskip\z@
  482.     \egroup
  483.     \setbox\@tempboxa\hbox{\float@rotation{\box\@tempboxa}}%
  484.     \centerline{\box\@tempboxa}%
  485.   \expandafter\end\expandafter{\curr@landfloat}}
  486. % \boxput
  487. \def\boxput{\@ifstar{\@testtrue\@boxput}{\@testfalse\@boxput}}
  488. \def\@boxput{\@ifnextchar({\@@boxput}{\@@boxput(0,0)}}
  489. \long\def\@@boxput(#1,#2)#3#4{%
  490.   \setbox\@fancybox\hbox{{#4}}%
  491.   \setbox\@tempboxa\vbox to\z@{\vss\hbox to\z@{\hss{#3}\hss}\vss}%
  492.   \@tempdima=#1\wd\@fancybox
  493.   \advance\@tempdima\wd\@fancybox
  494.   \divide\@tempdima 2
  495.   \ifcat a#2\relax
  496.     \@tempdimb=\z@
  497.   \else
  498.     \@tempdimb=.5\ht\@fancybox
  499.     \advance\@tempdimb.5\dp\@fancybox
  500.     \@tempdimc=\@tempdimb
  501.     \advance\@tempdimc-\dp\@fancybox
  502.     \@tempdimb=#2\@tempdimb
  503.     \advance\@tempdimb\@tempdimc
  504.   \fi
  505.   \setbox\@tempboxa\hbox to \z@{%
  506.     \if@test\kern-\wd\@fancybox\fi
  507.     \kern\@tempdima\raise\@tempdimb\box\@tempboxa\hss}%
  508.   \ht\@tempboxa=\z@ \dp\@tempboxa=\z@
  509.   \leavevmode
  510.   \if@test
  511.     \hbox{\box\@fancybox\box\@tempboxa}%
  512.   \else
  513.     \hbox{\box\@tempboxa\box\@fancybox}%
  514.   \fi}
  515. % \Vfootnotes
  516. \def\VerbatimFootnotes{\let\@footnotetext\V@footnotetext}
  517. \long\def\V@footnotetext{%
  518.   \afterassignment\V@@footnotetext
  519.   \let\@tempa}
  520. \def\V@@footnotetext{%
  521.   \insert\footins\bgroup
  522.   \csname reset@font\endcsname
  523.   \footnotesize
  524.   \interlinepenalty\interfootnotelinepenalty
  525.   \splittopskip\footnotesep
  526.   \splitmaxdepth\dp\strutbox
  527.   \floatingpenalty \@MM
  528.   \hsize\columnwidth
  529.   \@parboxrestore
  530.   \edef\@currentlabel{\csname p@footnote\endcsname\@thefnmark}%
  531.   \@makefntext{}%
  532.   \rule{\z@}{\footnotesep}%
  533.   \bgroup
  534.   \aftergroup\V@@@footnotetext
  535.   \ignorespaces}
  536. \def\V@@@footnotetext{\strut\egroup}
  537. % Verbatim
  538. % The main idea is to separate the reading and formatting of the
  539. % verbatim listing. It's pretty simple.
  540. \def\Verbatim@Codes{%
  541.   \let\do\@makeother
  542.   \dospecials
  543.   \Verbatim@ObeyThings
  544.   \ThisVerbCodes\relax\gdef\ThisVerbCodes{}}
  545. \def\EveryVerbatimCodes{}
  546. % \Verbatim is redefined temporarilly in \Get@Verbatim to scan the
  547. % verbatim text. \Verbatim is used so that error messages are more
  548. % enlightening. \next checks whether \Verbatim found its argument,
  549. % and attempts to recover if not.
  550. % Heuristically, if current environment is `foo' and argument of
  551. % \Get@Verbatim is \The@Verbatim, then definition of \Verbatim is
  552. % \def\Verbatim#1^^M#2^^M\the\EndVerbatimTokens\end{foo}{%
  553. %  \xdef\The@Verbatim{\noexpand\Every@VerbatimLine#2}%
  554. %  \endgroup\end{foo}}
  555. % \The@Verbatim is then equal to the verbatim text, with spaces
  556. % replaced by \Verbatim@Space, tabs replaced by \Verbatim@Tab,
  557. % and ` replaced by \@lquote. In addition, each line begins with
  558. % \Every@VerbatimLine, and each line but the last ends with
  559. % \Verbatim@Par. It is then possible to redefine these when formatting
  560. % the verbatim text. To insert each line as an argument to \foo, use
  561. %   \def\Every@VerbatimLine#1\Verbatim@Par{\foo{#1}}
  562. %   \The@Verbatim\Verbatim@Par
  563. \newtoks\EndVerbatimTokens
  564. \begingroup
  565.   \catcode`\|=0
  566.   \catcode`\[=1
  567.   \catcode`\]=2
  568.   \catcode`\{=12
  569.   \catcode`\}=12
  570.   \catcode`\^^M=13%
  571.   \catcode`\\=12%
  572.   |gdef|Get@Verbatim#1[%
  573.     |begingroup%
  574.       |Verbatim@Codes|EveryVerbatimCodes%
  575.       |let|protect|noexpand%
  576.       |VerbatimEnvironment%
  577.       |edef|next[|noexpand|def|noexpand|Verbatim####1|noexpand^^M####2%
  578.         |noexpand^^M|the|EndVerbatimTokens\end{|@VerbEnvir}]%
  579.       |edef|endVerbatim[|noexpand|endgroup|noexpand|end[|@VerbEnvir]]%
  580.       |global|let|@VerbEnvir|relax%
  581.       |next[|@nil|xdef#1[|noexpand|Every@VerbatimLine##2]|endVerbatim]%
  582.       |def|next[|@ifnextchar|@nil[|@gobble]%     If \@nil is there, then
  583.         [|gdef#1[]|endVerbatim|end[document]]]%  \Verbatim found its argument.
  584.       |expandafter|next|Verbatim]%               Otherwise, try to recover.
  585.   |gdef|AltGet@Verbatim#1[%
  586.     |begingroup%
  587.       |Verbatim@Codes|EveryVerbatimCodes%
  588.       |def^^M##1^^M##2[%
  589.         |ifx|@nil##2|@empty|else%
  590.           |noexpand|Verbatim@Par|noexpand|Every@VerbatimLine##1%
  591.           |expandafter^^M|expandafter##2%
  592.         |fi]%
  593.       |let|protect|noexpand%
  594.       |VerbatimEnvironment%
  595.       |edef|next[|noexpand|def|noexpand|Verbatim####1|noexpand^^M####2%
  596.         \end{|@VerbEnvir}]%
  597.       |edef|endVerbatim[|noexpand|endgroup|noexpand|end[|@VerbEnvir]]%
  598.       |global|let|@VerbEnvir|relax%
  599.       |next[|@nil|xdef#1[|noexpand|Every@VerbatimLine##2^^M|@nil]|endVerbatim]%
  600.       |def|next[|@ifnextchar|@nil[|@gobble]%
  601.         [|gdef#1[]|endVerbatim|end[document]]]%
  602.       |expandafter|next|Verbatim]%
  603. |endgroup
  604. \def\AltGetVerbatim{\let\Get@Verbatim\AltGet@Verbatim}
  605. % It is enough to not use \begin or \end when defining new verbatim
  606. % environments, as the default is for \Get@Verbatim to look for the
  607. % end of the current environment, but using \VerbatimEnvironment
  608. % is easier to explain to users.
  609. \def\VerbatimEnvironment{%
  610.   \ifx\@VerbEnvir\relax\xdef\@VerbEnvir{\@currenvir}\fi}
  611. \let\@VerbEnvir\relax
  612. \def\The@VerbatimErr{%
  613.   \gdef\The@Verbatim{\@latexerr{Misplaced \string\end{Verbatim}}\@ehd}}
  614. \The@VerbatimErr
  615. \begingroup
  616. \catcode`\^^M=\active%
  617. \catcode`\ =\active%
  618. \catcode`\^^I=\active%
  619. \gdef\Verbatim@ObeyThings{%
  620. \catcode`\^^M=\active%
  621. \catcode`\ =\active%
  622. \catcode`\^^I=\active%
  623. \catcode``=\active%
  624. \def^^M{\noexpand\Verbatim@Par\noexpand\Every@VerbatimLine}%
  625. \def^^I{\noexpand\Verbatim@Tab}%
  626. \def {\noexpand\Verbatim@Space}%
  627. \Verbatim@NoLigs}%
  628. \gdef\Verbatim@DontObeyLines{\outer\def^^M{}}%
  629. \endgroup
  630. \def\SaveVerbatim{\@bsphack\Get@Verbatim}
  631. \def\endSaveVerbatim{\@esphack}
  632. {\catcode``13 \gdef\Verbatim@NoLigs{\def`{\noexpand\@lquote}}}
  633. \def\Verbatim@Prep{%
  634.   \frenchspacing
  635.   \ThisVerb\relax\gdef\ThisVerb{}%
  636.   \VerbatimFont
  637.   \EveryVerbatim
  638.   \let\Every@VerbatimLine\EveryVerbatimLine
  639.   \def\Verbatim@Space{\leavevmode\penalty\@M\VerbatimSpace}%
  640.   \def\Verbatim@Tab{\leavevmode\penalty\@M\VerbatimTab}}%
  641. \def\Verb@Prep{%
  642.   \frenchspacing
  643.   \ThisVerb\relax\gdef\ThisVerb{}%
  644.   \VerbFont
  645.   \EveryVerb
  646.   \let\Every@VerbatimLine\EveryVerbatimLine
  647.   \def\Verbatim@Space{\leavevmode\penalty\@M\VerbSpace}%
  648.   \def\Verbatim@Tab{\leavevmode\penalty\@M\VerbTab}}%
  649. \def\Verbatim@Par{\leavevmode\null\@@par\penalty\interlinepenalty}
  650. % Parameter initialization:
  651. \def\VerbatimSpace{\ }
  652. {\catcode`\ =12\gdef\ttspace{{\tt }}}
  653. \def\VerbSpace{\ }
  654. \def\VerbatimTab{\ \ \ \ \ \ \ \ }
  655. \def\VerbTab{\ }
  656. \def\EveryVerbatim{}
  657. \def\EveryVerb{}
  658. \def\ThisVerb{}
  659. \def\EveryVerbatimLine{}%
  660. \def\EveryVerbOutLine{}
  661. \def\VerbatimFont{\tt}
  662. \def\VerbFont{\tt}
  663. \def\VerbatimFuzz{2pt}%
  664. \def\EveryVerbatimCodes{}
  665. \def\EveryVerbCodes{}
  666. \def\EveryVerbOutCodes{}
  667. \def\ThisVerbCodes{}
  668. \def\Verbatim@List#1{%
  669.   \if@minipage\else\vskip\parskip\fi
  670.   \leftskip\@totalleftmargin
  671.   \@rightskip\@flushglue \rightskip\@rightskip
  672.   \parindent\z@
  673.   \parskip\z@
  674.   \parfillskip\@flushglue
  675.   \hfuzz\VerbatimFuzz\relax
  676.   \@@par
  677.   \global\@inlabelfalse  %Prevents vspace from being inserted when
  678.   \Verbatim@Prep         %first line exceeds \hsize.
  679.   #1%
  680.   \Verbatim@Par}%
  681. \def\UseVerbatim#1{%
  682.   \begingroup\trivlist\item[]\Verbatim@List{#1}\endtrivlist\endgroup}
  683. \def\Verbatim{\Get@Verbatim\The@Verbatim}
  684. \def\endVerbatim{\UseVerbatim\The@Verbatim\The@VerbatimErr}
  685. \def\LUseVerbatim#1{%
  686.   \begingroup\list{}{}\item[]\Verbatim@List{#1}\endlist\endgroup}
  687. \def\LVerbatim{\Get@Verbatim\The@Verbatim}
  688. \def\endLVerbatim{\LUseVerbatim\The@Verbatim\The@VerbatimErr}
  689. \def\BUseVerbatim{%
  690.   \@ifnextchar[{\@BUseVerbatim}{\@BUseVerbatim[]}}
  691. \def\@BUseVerbatim[#1]#2{%
  692.   \begingroup
  693.     \Verbatim@Prep
  694.     \def\Verbatim@Par{\@Btrivlistcr}%
  695.     \@Btrivlist{l}[#1]%
  696.     #2%
  697.     \endBtrivlist
  698.   \endgroup}%
  699. \def\BVerbatim{%
  700.   \catcode`\^^M=13\relax
  701.   \@ifnextchar[{\@BVerbatim}{\@BVerbatim[]}}
  702. \def\@BVerbatim[#1]{\def\@tempa{[#1]}\Get@Verbatim\The@Verbatim}
  703. \def\endBVerbatim{
  704.   \expandafter\@BUseVerbatim\@tempa\The@Verbatim\The@VerbatimErr}
  705. \newwrite\Verbatim@Outfile
  706. \def\VerbatimOut#1{%
  707.   \@bsphack
  708.   \begingroup
  709.     \immediate\openout\Verbatim@Outfile #1\relax
  710.     \def\EveryVerbatimCodes{\EveryVerbOutCodes}%
  711.     \Get@Verbatim\The@Verbatim}
  712. \def\endVerbatimOut{%
  713.     \Verbatim@ObeyThings
  714.     \def\Verbatim@Par{^^J}%
  715.     \def\Verbatim@Space{\space}%
  716.     \def\Verbatim@Tab{\space}%
  717.     \def\@lquote{\string`}%
  718.     \ThisVerb\relax\gdef\ThisVerb{}%
  719.     \let\Every@VerbatimLine\EveryVerbOutLine
  720.     \immediate\write\Verbatim@Outfile{\The@Verbatim}%
  721.     \immediate\closeout\Verbatim@Outfile
  722.   \endgroup
  723.   \The@VerbatimErr
  724.   \@esphack}
  725. % This one is a little tricky because:
  726. % * we want to ignore the ^^M at the end of the last line,
  727. % * we want to handle files that end with newline and files that don't
  728. % * we want comment characters to work properly,
  729. % * we want to expand each line before inserting \Every@VerbatimLine and
  730. %     \Verbatim@Par,
  731. % \The@GVerbatim is used as scratch with global redefinition.
  732. \newread\Verbatim@Infile
  733. \def\Verbatim@Input#1#2{%
  734.   \begingroup
  735.     \Verbatim@Codes\EveryVerbatimCodes
  736.     \immediate\openin\Verbatim@Infile #1\relax
  737.     \ifeof\Verbatim@Infile
  738.       \@latexerr{No verbatim file #1}\@ehd
  739.     \else
  740.       \def\The@GVerbatim{}\Verbatim@NextLine
  741.       \ifeof\Verbatim@Infile
  742.         \@latexerr{Verbatim file #1 is empty}\@ehd
  743.       \else
  744.         \let\The@Verbatim\The@GVerbatim
  745.         \def\The@GVerbatim{}\Verbatim@NextLine
  746.         #2{\Verbatim@@Input}%
  747.       \fi
  748.     \fi
  749.     \immediate\closein\Verbatim@Infile
  750.  \endgroup}
  751. \def\Verbatim@@Input{%
  752.   \let\protect\noexpand
  753.   \edef\The@Verbatim{%
  754.     \noexpand\Every@VerbatimLine
  755.     \The@Verbatim
  756.     \ifeof\Verbatim@Infile\else\noexpand\Verbatim@Par\fi}%
  757.   \let\protect\relax
  758.   \The@Verbatim
  759.   \ifeof\Verbatim@Infile\else
  760.     \let\The@Verbatim\The@GVerbatim
  761.     \def\The@GVerbatim{}\Verbatim@NextLine
  762.     \expandafter\Verbatim@@Input
  763.   \fi}%
  764. \begingroup\catcode`\^^M=\active%
  765. \gdef\Verbatim@NextLine{%
  766.   \ifeof\Verbatim@Infile\else%
  767.     \immediate\read\Verbatim@Infile to\@tempa%
  768.     \expandafter\Verbatim@@NextLine\@tempa^^M\relax^^M\@nil%
  769.   \fi}%
  770. % #2 is empty if line ends in ^^M, #2=\relax otherwise.
  771. \gdef\Verbatim@@NextLine#1^^M#2^^M#3\@nil{%
  772.   \expandafter\gdef\expandafter\The@GVerbatim\expandafter{\The@GVerbatim#1}%
  773.   \ifx#2\@empty\@empty\else\expandafter\Verbatim@NextLine\fi}%
  774. \endgroup%
  775. \def\UseVerb#1{\begingroup\Verb@Prep#1\endgroup}
  776. \def\SaveVerb{\@ifnextchar[{\Save@Verb}{\Save@Verb[]}}
  777. \long\def\Save@Verb[#1]#2{%
  778.   \begingroup
  779.     \Verbatim@Codes\Verbatim@DontObeyLines\EveryVerbCodes
  780.     \Save@@Verb{#1}{#2}}
  781. \long\def\Save@@Verb#1#2#3{%
  782.   \let\protect\noexpand
  783.   \def\next{\@ifnextchar\@nil{\@gobble}{\endgroup}}%
  784.   \long\def\Verb##1#3{\@nil\xdef#2{##1}\endgroup#1}%
  785.   \expandafter\next\Verb}
  786. \def\Verb{\Save@Verb[\UseVerb{\The@Verbatim}]{\The@Verbatim}}
  787. \def\VerbatimInput#1{\begingroup\Verbatim@Input{#1}\UseVerbatim\endgroup}
  788. \def\LVerbatimInput#1{\begingroup\Verbatim@Input{#1}\LUseVerbatim\endgroup}
  789. \def\BVerbatimInput{\@ifnextchar[{\@BVerbatimInput}{\@BVerbatimInput[]}}
  790. \def\@BVerbatimInput[#1]#2{%
  791.   \begingroup\Verbatim@Input{#2}{\@BUseVerbatim[#1]}\endgroup}
  792. \endinput
  793. %% END fancybox.sty
  794. %% BEGIN fancybox.doc
  795. %% COPYRIGHT 1992, by Timothy Van Zandt, tvz@Princeton.EDU.
  796. %% For copying restrictions, see fancybox.sty.
  797. %% Documentation for fancybox.sty.
  798. %% Run through LaTeX, with or without the NFSS.
  799. \def\FileVersion{1.0}
  800. \def\FileDate{93/02/10}
  801. %% This creates two temporary files: \jobname.ex1 and \jobname.tmp
  802. \documentstyle[12pt]{article}
  803. \makeatletter
  804. %% INPUT FANCYBOX.STY HERE TO CHECK FILE VERSION.
  805. \input fancybox.sty
  806. \ifx\FileVersion\fileversion\else
  807.   \@latexerr{Fancybox style file and documentation do not have the same
  808.     version}\@ehd
  809. %% DATES, VERSIONS AND TITLES:
  810. \def\expanddate#1/#2/#3/{\year=19#1 \month=#2 \day=#3}
  811. \begingroup
  812.   \expandafter\expanddate\filedate/
  813.   \xdef\thefiledate{\today}
  814. \endgroup
  815. \title{Documentation for fancybox.sty:\\
  816.   Box tips and tricks for \LaTeX}
  817. \author{Timothy Van Zandt\\ tvz@Princeton.EDU}
  818. \date{Version \fileversion\\ \thefiledate}
  819. \def\@maketitle{%
  820.  \begin{center}
  821.    {\Large\bf \@title \par}
  822.    \vskip 1.2em {\lineskip .5em
  823.    \begin{tabular}[t]{c}\@author\end{tabular}\par}
  824.    \vskip .8em {\@date}%
  825.   \end{center}
  826.   \par
  827.   \vskip .5em}
  828. %% PAGE STYLE:
  829. \pagestyle{myheadings}
  830. \if@twoside
  831.   \markboth{Documentation for fancybox.sty}%
  832.     {Version \fileversion, \thefiledate}%
  833. \else
  834.   \markright{fancybox.sty, Version \fileversion}
  835. %% PAGE PARAMETERS:
  836. % Paragraphs are marked by large space rather than indentation:
  837. \parindent 0pt
  838. \parskip 7pt plus 1pt minus 1pt
  839. \setlength{\topmargin}{0pt}
  840. \setlength{\headheight}{12pt}        % height of running head
  841. \setlength{\headsep}{30pt}           % distance between header and text
  842. \setlength{\textheight}{8.2in}        % height of text on page
  843. %% TABLE OF CONTENTS
  844. \newskip\myskip
  845. \def\tableofcontents{%
  846.   \par\vfill
  847.   \begin{quote}
  848.     \begin{center} \Large\bf Contents \end{center}
  849.     \def\numberline##1{\hbox to 0pt{\hss##1\hskip 1em}}%
  850.     \let\oldaddvspace\addvspace
  851.     \def\addvspace##1{%
  852.       \myskip##1\relax
  853.       \oldaddvspace{.5\myskip}}
  854.     \@starttoc{toc}%
  855.   \end{quote}
  856.   \thispagestyle{empty}
  857.   \vfill
  858.   \clearpage}
  859. %% VERBATIM HACKS:
  860. \VerbatimFootnotes
  861. % Short meta (works in verbatim. Can't use < for other purposes.
  862. \catcode`\<=13 \def<#1>{{\rm\it #1\/}}    % <meta> (works in verbatim)
  863. % Short verbatim. " can appear in verbatim environments.
  864. \def\temp{\Verb"}
  865. \expandafter\def\expandafter\dospecials\expandafter{\dospecials\do\"}
  866. \catcode`\"=13
  867. \let"\temp
  868. % Verbatim item:
  869. \newcommand{\vitem}{\SaveVerb[{\def\bf{}\item[\UseVerb{\MyTemp}]}]{\MyTemp}}
  870. %% EXAMPLES:
  871. \setlength{\fboxsep}{6pt}
  872. \begin{VerbatimOut}{\jobname.ex1}
  873. % 1. Save example verbatim to \jobname.tmp,
  874. % 2. Input verbatim with \catcode`\"=14 (" is a comment).
  875. % 3. Input again with \catcode\`"=9 (" is ignored).
  876. \renewcommand{\EveryVerbatimLine}[2]{}
  877. \renewcommand{\EveryVerbOutLine}[2]{}
  878. \newcommand{\BeginExample}{%
  879.   \VerbatimEnvironment\begin{VerbatimOut}{\jobname.tmp}}
  880. \newcommand{\EndExample}{%
  881.   \end{VerbatimOut}%.
  882.   \renewcommand{\EveryVerbatimLine}{}%
  883.   \renewcommand{\EveryVerbatimCodes}{\catcode`\"=14}%
  884.   \LVerbatimInput{\jobname.tmp}%
  885.   \catcode`\"=9}
  886. \newenvironment{example}{\BeginExample}{\EndExample
  887.   \begin{center}\input{\jobname.tmp}\end{center}}
  888. \newenvironment{example*}{\BeginExample}%
  889.   {\EndExample \input{\jobname.tmp}}
  890. \newenvironment{example**}{\BeginExample}%
  891.   {\EndExample \globaldefs=1 \input{\jobname.tmp}}
  892. \end{VerbatimOut}
  893. \input{\jobname.ex1}
  894. %% END PREAMBLE:
  895. \makeatother
  896. \begin{document}
  897. \setcounter{page}{0}
  898. \maketitle
  899. \begin{quote}
  900. "fancybox.sty", together with its documentation, gives extensive answers to
  901. and solutions for many questions about how to frame or rotate this or that in
  902. \LaTeX. It also contains commands for shadow, double and oval frames.
  903. \end{quote}
  904. \tableofcontents
  905. \section{Fancy frames}
  906. "fancybox.sty" has five variants of \LaTeX's "\fbox" command:
  907. \begin{quote}\raggedright
  908. "\shadowbox", "\doublebox", "\ovalbox" (with "\thinlines") and "\Ovalbox"
  909. (with "\thicklines").
  910. \end{quote}
  911. Here are examples:\footnote{In this documentation, the default value of
  912. "\fboxsep" has been changed from 3pt to 6pt.}
  913. \begin{example}
  914.   \shadowbox{\large\bf New Glarus Birdwatch}
  915. \end{example}
  916. \begin{example}
  917.   \doublebox{\large\bf New Glarus Birdwatch}
  918. \end{example}
  919. \begin{example}
  920.   \ovalbox{\large\bf New Glarus Birdwatch}
  921. \end{example}
  922. \begin{example}
  923.   \Ovalbox{\large\bf New Glarus Birdwatch}
  924. \end{example}
  925. The distance between the box and the frame is "\fboxsep", as with \LaTeX's
  926. "\fbox" command. The commands use other parameters as well:
  927. \begin{description}
  928. \vitem"\shadowbox" The width of the frame is "\fboxrule" (the same as with
  929. "\fbox"). The width of the shadow is "\shadowsize" (default: "4pt").
  930. \vitem"\doublebox" The width of the inner frame is .75"\fboxrule", and the
  931. width of the outer frame is 1.5"\fboxrule". The distance between the two
  932. frames is 1.5"\fboxrule" plus .5pt.
  933. \vitem"\ovalbox" The width of the frame is set by the "\thinlines"
  934. declaration. The diameter of the corner arcs is set with the "\cornersize"
  935. command.
  936. \begin{LVerbatim}
  937.   \cornersize{<num>}
  938. \end{LVerbatim}
  939. sets the diameter of the corners arcs to <num> times the lessor of the width
  940. and height of the box.
  941. \begin{LVerbatim}
  942.   \cornersize*{<dim>}
  943. \end{LVerbatim}
  944. sets the diameter of the corner arcs to <dim>. This is all approximate,
  945. because \LaTeX\ has a limited range of arc sizes to choose from. The default
  946. \begin{LVerbatim}
  947.   \cornersize{.5}
  948. \end{LVerbatim}
  949. \vitem"\Ovalbox" This is like "\ovalbox", except that the width of the lines
  950. is set by the "\thicklines" declaration.
  951. \end{description}
  952. There are no analogs to \LaTeX's "\framebox" command, which has various
  953. optional arguments not supported by "\fbox". You can get the exact same
  954. functionality by putting the argument of the above framing commands in a
  955. "\makebox".
  956. There is also a variant "\fancyoval" of \LaTeX's "\oval" picture object. The
  957. difference is that "\oval" always makes the diameter of the corner arcs as
  958. large as possible, and "\fancyoval" uses the "\cornersize" command to set the
  959. diameter.
  960. \section{A short course on boxes}
  961. \begingroup\sloppy
  962. The "\shadowbox", "\doublebox", "\ovalbox" and "\Ovalbox" commands described
  963. in the previous section are examples of LR-box commands, meaning that their
  964. argument is processed in LR mode. \LaTeX\ LR-box commands include "\mbox",
  965. "\makebox", "\fbox", "\framebox", "\sbox" and "\savebox". All the PSTricks
  966. commands whose argument is text are LR-box commands, including, e.g, the
  967. framing, rotating, scaling and positioning commands, and some of the node
  968. commands. Any rotation command is an LR-box command.
  969. \endgroup
  970. The purpose of the rest of this documentation is to provide answers to, and
  971. solutions for, frequently asked questions about using LR-box commands with
  972. \LaTeX. I will use "\fbox" for the leading example of a box framing
  973. command,\footnote{In the examples using "\fbox", be aware that the default
  974. value of "\fboxsep" has been changed in this documentation from 3pt to 6pt.}
  975. and "\rotateleft" for the leading example of a box rotation command.
  976. ("fancybox.sty" does not contain a "\rotateleft" commands, as this must be
  977. implemented via "\special"'s, but there are numerous box-rotation style files
  978. around.) However, most of what is said here applies to any LR-box command.
  979. In each LR-box command, the text is processed in restricted horizontal mode,
  980. which is referred to as ``LR-mode'' in Lamport's {\em \LaTeX: User's Guide and
  981. Reference Manual}. In restricted horizontal mode, the input, consisting of
  982. regular characters and boxes, is made into one (long or short) line. There is
  983. no line-breaking, nor can there be vertical mode material such as an entire
  984. displayed equation. However, the fact that you can include another box means
  985. that this isn't really a restriction.
  986. For one thing, alignment environments such as \LaTeX's "tabular" are just
  987. boxes, and thus present no problem. Picture environments and the LR-box
  988. commands themselves are also just boxes. Entire paragraphs or other vertical
  989. mode material such as displayed equations can be nested in a "\parbox" or
  990. "minipage".
  991. \section{Defining LR-box environments}
  992. To frame a "minipage", you have to write
  993. \begin{LVerbatim}
  994.   \fbox{%
  995.     \begin{minipage}{3in}
  996.       blah
  997.     \end{minipage}}
  998. \end{LVerbatim}
  999. You might want to define an environment "fminipage" that frames its contents,
  1000. but you can't use
  1001. \begin{LVerbatim}
  1002.   \newenvironment{fminipage}%
  1003.     {\fbox{\begin{minipage}}%
  1004.     {\end{minipage}}}
  1005. \end{LVerbatim}
  1006. because the braces are not balanced in the definition.
  1007. "fancybox.sty" contains an "Sbox" environment that makes it easy to define
  1008. your own LR-box environments. It is a variant of \LaTeX's "\sbox" command that
  1009. saves the contents of the environment in a storage bin that can be retrieved
  1010. with the command "\TheSbox".\footnote{The difference between
  1011. \begin{LVerbatim}
  1012.   \begin{Sbox}
  1013.     blah
  1014.   \end{Sbox}
  1015.   \TheSbox
  1016. \end{LVerbatim}
  1017. \begin{LVerbatim}
  1018.   \newsavebox{\mybox}
  1019.   \sbox{\mybox}{blah}
  1020.   \usebox{\mybox}
  1021. \end{LVerbatim}
  1022. is that "Sbox" saves the contents globally, and "\TheSbox" erases the contents
  1023. globally.}
  1024. For example, here is a framed minipage:
  1025. \begin{LVerbatim}
  1026.   \begin{Sbox}
  1027.     \begin{minipage}{3in}
  1028.       blah
  1029.     \end{minipage}
  1030.   \end{Sbox}
  1031.   \fbox{\TheSbox}
  1032. \end{LVerbatim}
  1033. and here is an "fminipage" environment that works:
  1034. \begin{example**}
  1035.   \newenvironment{fminipage}%
  1036.     {\begin{Sbox}\begin{minipage}}%
  1037.     {\end{minipage}\end{Sbox}\fbox{\TheSbox}}
  1038. \end{example**}
  1039. Let's see that it really works:
  1040. \begin{example}
  1041.   \begin{fminipage}{2in}
  1042.     Since the former doesn't use braces to delimit
  1043.     the contents of the box, $\ldots$
  1044.   \end{fminipage}
  1045. \end{example}
  1046. \section{Math}
  1047. In-line math, or pieces of a displayed equation (as opposed to a whole
  1048. equation), are horizontal mode material, but most LR-box commands switch out
  1049. of math mode when they occur in math mode. Thus, you have to explicitly switch
  1050. back in to math mode when desired.\footnote{This is {\em not} true for the
  1051. PSTricks LR-box commands.}
  1052. For example:
  1053. \begin{example}
  1054.   $x + y = \fbox{$\Omega$}$
  1055. \end{example}
  1056. You also have to explicitly write
  1057. \begin{quote}
  1058.   "\scriptstyle", "\scriptscriptstyle" or "\displaystyle"
  1059. \end{quote}
  1060. if you want one of these special math styles. For example, here I will frame
  1061. an equation, but not the equation number:
  1062. \begin{example*}
  1063.   \begin{equation}
  1064.     \fbox{$\displaystyle
  1065.       \int_{\Omega_0} \zeta(\omega) d\omega
  1066.       \geq \bar{r}$}
  1067.   \end{equation}
  1068. \end{example*}
  1069. Entire displayed equations or "eqnarray" environments work differently because
  1070. they are vertical mode material. Thus, they have to go inside a "\parbox" or
  1071. "minipage". E.g.,
  1072. \begin{example*}
  1073.   \newlength{\mylength}
  1074.     \setlength{\fboxsep}{15pt}
  1075.     \setlength{\mylength}{\linewidth}
  1076.     \addtolength{\mylength}{-2\fboxsep}
  1077.     \addtolength{\mylength}{-2\fboxrule}
  1078.     \fbox{%
  1079.       \parbox{\mylength}{
  1080.         \setlength{\abovedisplayskip}{0pt}
  1081.         \setlength{\belowdisplayskip}{0pt}
  1082.         \begin{equation}
  1083.           x + y = z
  1084.         \end{equation}}}
  1085. \end{example*}
  1086. The outer "\[" "\]" are just used to display the boxed equation, rather than
  1087. actually switch into math mode. Note how I set the width of the "\parbox" so
  1088. that the displayed box would exactly have width "\linewidth".\footnote{That is
  1089. what "\mylength" is for. It is better to define a single scratch length that
  1090. you reuse rather than creating a new one each time.}
  1091.  I also set the display skips to "0pt" and increased the size of "\fboxsep" so
  1092. that I would have the same distance all around between the equation and the
  1093. frame.
  1094. This is again a mouthful, and so I might instead define:\footnote{The reason
  1095. for using "\minipage" instead of "\begin{minipage}", and so on, is that with
  1096. AmS-\LaTeX, "\begin" and "\end" cannot appear in the definition of a new
  1097. equation environment.}
  1098. \begin{example**}
  1099.   \newenvironment{FramedEqn}%
  1100.     {\setlength{\fboxsep}{15pt}
  1101.       \setlength{\mylength}{\linewidth}%
  1102.       \addtolength{\mylength}{-2\fboxsep}%
  1103.       \addtolength{\mylength}{-2\fboxrule}%
  1104.       \Sbox
  1105.       \minipage{\mylength}%
  1106.          \setlength{\abovedisplayskip}{0pt}%
  1107.          \setlength{\belowdisplayskip}{0pt}%
  1108.          \equation}%
  1109.     {\endequation\endminipage\endSbox
  1110.       \[\fbox{\TheSbox}\]}
  1111. \end{example**}
  1112. "fancybox.sty" doesn't bother defining any such environments, because there
  1113. are too many possible designs. But let's see if the one above works:
  1114. \begin{example*}
  1115.   \begin{FramedEqn}
  1116.     \Rightarrow P\sim\xi(P_\gamma)- \frac{1}{3}
  1117.   \end{FramedEqn}
  1118. \end{example*}
  1119. "fancybox.sty" contains a "Beqnarray" environment, which is like the
  1120. "eqnarray" environment but it is not vertical mode material. Instead, it
  1121. produces a box just large enough to hold all the equations. For example:
  1122. \begin{example}
  1123.   \fbox{%
  1124.     \begin{Beqnarray*}
  1125.       x & = & y\\
  1126.       y & > & x \\
  1127.       \int_4^5 f(x)dx & = & \sum_{i\in F} x_i
  1128.     \end{Beqnarray*}}
  1129. \end{example}
  1130. The unstarred version produces standard equation numbers on the right (even
  1131. with the "leqno" style option and AmS-\LaTeX). It might not work with special
  1132. equation numbering macros.
  1133. \section{Floats}\label{floats}
  1134. A common mistake is to put a whole "table", "figure" or other float
  1135. environment inside an LR-box command. Instead, you should put everything that
  1136. is {\em inside} the environment (including the "\caption", if you want that
  1137. boxed too) inside a "minipage" of the desired width, and then put the
  1138. "minipage" inside the LR-box command.
  1139. For example:
  1140. \begin{example*}
  1141.   \begin{table}[h]
  1142.     \begin{center}
  1143.       \fbox{%
  1144.         \begin{minipage}{.8\textwidth}
  1145.           \begin{center}
  1146.             \begin{tabular}{rl}
  1147.               foo & bar
  1148.             \end{tabular}
  1149.           \end{center}
  1150.           \caption{A table of foo and bar.}
  1151.         \end{minipage}}
  1152.     \end{center}
  1153.   \end{table}
  1154. \end{example*}
  1155. Note how I had to use "center" twice: once to center the framed box, and again
  1156. to center the stuff inside the box.
  1157. That is a mouthful, and so I might define a "FramedTable" environment like the
  1158. following, which sets the size of the "minipage" so that the framed box is
  1159. exactly the width of the page (no need for the first "center" environment this
  1160. time):
  1161. \begin{example**}
  1162.   \newenvironment{FramedTable}%
  1163.     {\begin{table}[h]
  1164.       \begin{Sbox}%
  1165.       \setlength{\mylength}{\textwidth}%
  1166.       \addtolength{\mylength}{-2\fboxsep}%
  1167.       \addtolength{\mylength}{-2\fboxrule}%
  1168.       \begin{minipage}{\mylength}}%
  1169.     {\end{minipage}\end{Sbox}\fbox{\TheSbox}\end{table}}%
  1170. \end{example**}
  1171. Now let's see if it works:
  1172. \begin{example*}
  1173.   \begin{FramedTable}
  1174.     \begin{center}
  1175.       \begin{tabular}{rl}
  1176.         foo & bar
  1177.       \end{tabular}
  1178.     \end{center}
  1179.     \caption{A table of foo and bar.}
  1180.   \end{FramedTable}
  1181. \end{example*}
  1182. The most common reason to want to rotate an entire float, caption and all, is
  1183. to put it on a page by itself in landscape mode, centered both horizontally
  1184. and vertically. Compared to the table framing we did above, we just have to
  1185. replace "\fbox" by our box rotation command (e.g., "\rotateleft" or whatever),
  1186. set the width of the minipage to "\textheight" (if you want to use the full
  1187. size of the page), and use the float position specifier "[p]". "fancybox.sty"
  1188. contains an environment,
  1189. \begin{LVerbatim}
  1190.   \begin{landfloat}{<float>}{<rotation command>}
  1191.     ...
  1192.   \end{landfloat}
  1193. \end{LVerbatim}
  1194. that automates this. It has two arguments: the name of the floating
  1195. environment, and your rotation command. For example, if "\rotateleft{foo}"
  1196. rotates "foo" by 90 degrees, and you want a landscape mode "table", then try
  1197. \begin{LVerbatim}
  1198.   \begin{landfloat}{table}{\rotateleft}
  1199.     ...
  1200.   \end{landfloat}
  1201. \end{LVerbatim}
  1202. If the whole document is in landscape mode, then "landfloat" gives you a
  1203. portrait-mode float---good for a table that is too tall to fit in landscape
  1204. mode.
  1205. If you don't add a caption to a float, it doesn't matter much what floating
  1206. environment you use (e.g., "table", "figure" or whatever). Thus, you can put
  1207. anything in a landscape float. For example, suppose I have a very wide
  1208. equation. Then I can write:
  1209. \begin{LVerbatim}
  1210.   \begin{landfloat}{table}{\rotateleft}
  1211.     \begin{equation}
  1212.       ...
  1213.     \end{equation}
  1214.   \end{landfloat}
  1215. \end{LVerbatim}
  1216. "fancybox.sty" defines a generic caption, "\GenericCaption", that doesn't
  1217. affect the numbering of floats, doesn't make an entry in a list of floats, and
  1218. doesn't add anything to the argument you give. I could have used this if I
  1219. wanted to add a caption to the previous example.
  1220. \section{Center, flushleft and flushright}
  1221. There are two ways to box a "center", "flushleft" or "flushright" environment.
  1222. If you have long lines and you want \TeX\ to do the line breaking, then put
  1223. the environment inside a "minipage".\footnote{List and other such environments
  1224. work best inside a "minipage" environment rather than a "\parbox".} If you
  1225. have short lines and you want the frame to adjust itself to the size of the
  1226. longest line, then use "fancybox.sty"'s
  1227. \begin{quote}
  1228.   "Bcenter", "Bflushleft" or "Bflushright"
  1229. \end{quote}
  1230. environment instead.
  1231. These are basically just "tabular" environments with a single column, and so
  1232. each line should end with "\\", or "\\["<dim>"]" to insert extra space, and
  1233. the text on each line must be balanced. Also, each line is sitting in its own
  1234. group, and so, e.g., if you want to change the font for the whole environment,
  1235. you should do this before the environment rather than after.
  1236. Like the "tabular" environment, the box that is produced has the baseline at
  1237. the center, unless you include an optional argument "[t]" to align the box
  1238. with the top line or "[b]" to align the box with the bottom line.
  1239. For example:
  1240. \begin{example}
  1241.   \setlength{\fboxsep}{10pt}%
  1242.   \fbox{%
  1243.     \begin{Bcenter}
  1244.       Love of life\\
  1245.       and other short stories\\
  1246.       by Policarpa Salabarrieta
  1247.   \end{Bcenter}}
  1248. \end{example}
  1249. Compare this with:
  1250. \begin{example}
  1251.   \setlength{\fboxsep}{10pt}%
  1252.   \fbox{%
  1253.     \begin{minipage}{6cm}
  1254.     \begin{center}
  1255.       Love of life and other short stories
  1256.       by Policarpa Salabarrieta
  1257.     \end{center}
  1258.     \end{minipage}}
  1259. \end{example}
  1260. In either case, if we want the resulting framed box centered, we have to
  1261. include it inside another "center" environment.
  1262. Here is another example:
  1263. \begin{example}
  1264.   My list: \fbox{%
  1265.     \begin{Bflushleft}[b]
  1266.       Galanga root\\
  1267.       Coconut\\
  1268.       Tempeh
  1269.     \end{Bflushleft}}
  1270. \end{example}
  1271. \section{Lists}
  1272. There are again two ways to box a list environment such as
  1273. \begin{quote}
  1274.   "itemize", "enumerate" or "description".
  1275. \end{quote}
  1276. You can put it in a "minipage" of pre-determined size and let \TeX\ do the
  1277. line breaking, or you can use
  1278. \begin{quote}
  1279.   "Bitemize", "Benumerate" or "Bdescription"
  1280. \end{quote}
  1281. instead, and let the box adjust to the size of the longest line.
  1282. For example.
  1283. \begin{example}
  1284.   \fbox{%
  1285.     \begin{Bitemize}
  1286.       \item Groceries
  1287.       \item Clean hamster cages
  1288.       \item Pick up Peter
  1289.     \end{Bitemize}}
  1290. \end{example}
  1291.  Most of the usual list parameters are irrelevant except for "\itemsep" and
  1292. "\labelsep". These environments are also based on the "tabular" environment,
  1293. and so each item should be balanced text. You can't write "\vspace{4pt}"
  1294. either, but you can insert an extra amount of space before an item by writing
  1295. "\item(4pt)" (or "\item(4pt)[label]" if you have a label). Also, you can break
  1296. lines within an item using "\\" or "\\[<dim>]". For example:
  1297. \begin{example}
  1298.   \fbox{%
  1299.     \begin{Bdescription}
  1300.       \item[David] Groceries
  1301.       \item[Eli]  Hamster cages\\
  1302.                   Surreal numbers
  1303.       \item(3pt)[Doris] Pick up Peter
  1304.     \end{Bdescription}}
  1305. \end{example}
  1306. These environments also have an optional argument, "[t]" to align the box with
  1307. the top line, and "[b]" to align the box with the bottom line.
  1308. \begin{example}
  1309.   To do:
  1310.   \fbox{\setlength{\itemsep}{0pt}%
  1311.     \begin{Benumerate}[t]
  1312.       \item Groceries
  1313.       \item Hamster cages
  1314.       \item Pick up Peter
  1315.     \end{Benumerate}}
  1316. \end{example}
  1317. There is also a generic "\Blist" command that is analogous to \LaTeX's
  1318. "\list".  It has the same two obligatory arguments, plus a third optional
  1319. "[t]" or "[b]" argument for changing the alignment.
  1320. \section{Superimposing boxes}
  1321. The command
  1322. \begin{LVerbatim}
  1323.   \boxput*(<x>,<y>){<LR stuff1>}{<LR stuff2>}
  1324. \end{LVerbatim}
  1325. puts <LR stuff1> either behind (the default) or in front of (with the "*") <LR
  1326. stuff2>.\footnote{You will only notice the difference between "\boxput" and
  1327. "\boxput*" if you are using color implemented by "\special"'s} The resulting
  1328. box has the dimensions of <LR stuff2>.
  1329. The coordinates "(<x>,<y>)" determine where the center of <LR stuff1> is
  1330. positioned. For example, "(0,0)" puts it at the center of <LR stuff2>, "(0,1)"
  1331. puts it at the center-top, and "(-1,-1)" puts it in the bottom-left corner.
  1332. More generally, the origin of the coordinate system is at the center of <LR
  1333. stuff2>, one unit in the vertical direction is half the vertical size of <LR
  1334. stuff2>, and one unit in the horizontal direction is half the width of <LR
  1335. stuff2>. Thus, <x> and <y> should always be numbers (without units such as
  1336. "pt" or "cm"), with one exception: If <y> is "b" or "B", <LR stuff1> is
  1337. positioned vertically at the baseline of <LR stuff2>. "(<x>,<y>)" is
  1338. optional---the default is "(0,0)".
  1339. Except for the funny coordinate system, "\boxput" is like the "\put" command
  1340. in a "picture". In particular, you can use "\makebox" in <LR stuff1> to
  1341. fine-tune the positioning, and <LR-stuff1> can contain a "picture"
  1342. environment.
  1343. You might use "\boxput" to put a ``water mark'' in the background of a box, or
  1344. to put a label next to a box, when you don't want this label to take up any
  1345. space. Here is a lazy example:
  1346. \begin{example}
  1347.   \boxput{\makebox(0,0){\Huge Censored!}}{\parbox{3in}{%
  1348.     The origin of the coordinate system is at the center of
  1349.     {\em LR stuff2}, and one unit in the x-direction
  1350.     is half the width of {\em LR stuff2}.}}
  1351. \end{example}
  1352. This would be a lot more interesting using PSTricks, with ``Censored!'' in the
  1353. foreground, rotated 30 degrees, and red:
  1354. \begin{LVerbatim}
  1355.   \boxput*{\rput{30}{\Huge\red Censored}}{\parbox{3in}{%
  1356.     blah blah}}
  1357. \end{LVerbatim}
  1358. Here is another example using PSTricks:
  1359. \begin{LVerbatim}
  1360.   \newcommand{\titledframe}[2]{%
  1361.     \boxput*(0,1){\psframebox*{#1}}%
  1362.       {\psframebox[framesep=12pt]{#2}}}
  1363. \end{LVerbatim}
  1364. \newcommand{\titledframe}[2]{%
  1365.   \boxput*(0,1){#1}%
  1366.     {\fboxsep=12pt \fbox{#2}}}
  1367. The following example illustrated roughly how it works, but ``My title'' does
  1368. not blot out the frame behind it because this documentation does not use
  1369. PSTricks. \begin{example}
  1370.   \titledframe{My title}{%
  1371.     \parbox{2in}{The title is superimposed
  1372.       on the top part of the frame.}}
  1373. \end{example}
  1374. \section{Framing a whole page}
  1375. The commands
  1376. \begin{LVerbatim}
  1377.   \fancyput*(<x>,<y>){<LR stuff>}
  1378.   \thisfancyput*(<x>,<y>){<LR stuff>}
  1379. \end{LVerbatim}
  1380. are pretty much like "\put" commands in a \LaTeX\ picture environment whose
  1381. origin is 1 inch down and to the right from the top left corner of the
  1382. page.\footnote{Don't blame me for \TeX's peculiar 1 inch margins.} The only
  1383. differences are that (i) that any LR-mode material is permitted (including
  1384. \LaTeX\ "picture" environment, of course), (ii) the coordinate is optional
  1385. "(0pt,0pt)" is substituted by default), and (iii) if the coordinate is
  1386. included, you {\em must} specify the units.
  1387. "\thisfancyput" affects only the current page, and is a global declaration
  1388. (analogous to "\thispagestyle").
  1389. If you include the optional "*", then the command adds to, rather than
  1390. replaces, other things that have been inserted with "\fancyput" or
  1391. "\thisfancyput".
  1392. These commands are particularly useful for framing a page, because you can get
  1393. a frame that is, e.g., 1 inch from each side of the physical page without
  1394. having to worry about what margins you are using for the document. Here is an
  1395. example:
  1396. \begin{example*}
  1397.   \thisfancyput(3.25in,-4.5in){%
  1398.     \setlength{\unitlength}{1in}\fancyoval(7,9.5)}
  1399. \end{example*}
  1400. You could also use "\fancyput" to add some kind of ``watermark'' or background
  1401. image (e.g., a light gray ``DRAFT'').
  1402. There are other commands that directly frame or in some other way box the page
  1403. of text:
  1404. \begin{LVerbatim}
  1405.   \fancypage{<cmds1>}{<cmds2>}
  1406.   \thisfancypage{<cmds1>}{<cmds2>}
  1407. \end{LVerbatim}
  1408. Each finished page, before adding the headers and footers, (and thus having
  1409. width and height "\textwidth" and "\textheight", is boxed with
  1410. \begin{LVerbatim}
  1411.   <cmds1>{<pagebox>}
  1412. \end{LVerbatim}
  1413. Thus, <cmds1> should be, or should end with, a command whose argument can be a
  1414. box, such as "\fbox" or "\rotateleft".
  1415. Then the headers and footers are added, using the new width of the page, and
  1416. this is boxed with
  1417. \begin{LVerbatim}
  1418.   <cmds2>{<pagebox>}
  1419. \end{LVerbatim}
  1420. The same rules apply to <cmds2> as to <cmds1>.
  1421. Here is an example:
  1422. \begin{example*}
  1423.   \thisfancypage{%
  1424.     \setlength{\fboxsep}{8pt}%
  1425.     \setlength{\shadowsize}{8pt}%
  1426.     \shadowbox}{}
  1427. \end{example*}
  1428. {\bf Warning:} The commands described in this section change \LaTeX's output
  1429. routine, and may not work with document styles that do the same. Also, bad
  1430. arguments can cause serious errors with uninformative error messages.
  1431. \section{Switching to landscape mode midstream}
  1432. The most common reason to switch to landscape mode midstream is to rotate a
  1433. float, such as a table or figure. This was discussed in Section \ref{floats}.
  1434. If you want to rotate one or more pages, without rotating the headers and
  1435. footers, use the
  1436. \begin{LVerbatim}
  1437.   \begin{LandScape}{<cmd>}
  1438.     ...
  1439.   \end{LandScape}
  1440. \end{LVerbatim}
  1441. environment. <cmd> should be the command for rotating the page 90 degrees to
  1442. the left or right. (E.g., "\rotateleft", or "\rotate[l]".)
  1443. If you want to rotate the headers, footers and margins as well, use the
  1444. \begin{LVerbatim}
  1445.   \begin{Landscape}{<paperwidth>}{<paperheight>}{<cmd>}
  1446.     ...
  1447.   \end{Landscape}
  1448. \end{LVerbatim}
  1449. environment (the small "s" makes the difference) to rotate the pages left
  1450. (counterclockwise), and use the "Landscape*" environment (same arguments) to
  1451. rotate the pages right (clockwise). The three arguments are the width of the
  1452. paper, the height of the paper, and the rotation command you are using. For
  1453. example, if I have a portrait mode document using the US 8.5in by 11in paper,
  1454. and if "\rotateleft{foo}" rotates "foo" 90 degrees counterclockwise, then I
  1455. can write
  1456. \begin{LVerbatim}
  1457.   \begin{Landscape}{8.5in}{11in}{\rotateleft}
  1458. \end{LVerbatim}
  1459. You can use "\LandScape", "\Landscape" and "\Landscape*", rather then the
  1460. "LandScape", "Landscape" and "Landscape*" environments, if you want the rest
  1461. of the document to be in landscape mode.
  1462. If your document is being printed in landscape mode, then these environments 
  1463. switch to portrait mode.
  1464. For example, suppose I have a landscape mode document, and I want to switch to
  1465. portrait mode for the rest of the document, rotating the pages to the
  1466. ``right'' with "\rotateright". Then I would write
  1467. \begin{LVerbatim}
  1468.   \Landscape*{11in}{8.5in}{\rotateright}
  1469. \end{LVerbatim}
  1470. These environments switch the text width and height, leaving the margins
  1471. exactly as they were before. It is quite possible that you want to make other
  1472. changes to the page parameters after switching to landscape mode, but as
  1473. Lamport points out the \LaTeX\ {\em User's Guide and Reference Manual}, this
  1474. generally doesn't work right in the middle of the document. "fancybox.sty" has
  1475. a command "\UsePageParameters" which gets around this. It should be used right
  1476. after you change the page parameters (and the page parameter changes should
  1477. come right after the beginning of the landscape environment, or "\clearpage").
  1478. {\bf Warning:} The commands and environments described in this section change
  1479. \LaTeX's output routine, and may not work with document styles that do the
  1480. same. Also, bad arguments can cause serious errors with uninformative error
  1481. messages.
  1482. \section{Verbatim}
  1483. If you try to frame some verbatim text by typing
  1484. \begin{LVerbatim}
  1485.   \fbox{%
  1486.     \begin{minipage}{5cm}
  1487.       \begin{verbatim}
  1488.         \My \Program \Listing
  1489.         if { foo } { bar } fi
  1490.       \end{verbatim}
  1491.     \end{minipage}}
  1492. \end{LVerbatim}
  1493. you will get nonsense at best. This is because the argument to "\fbox" is read
  1494. before the "\begin{verbatim}" is processed. But then it is too late for \TeX\
  1495. to go back and interpret the contents of the verbatim environment literally
  1496. rather than as special \TeX\ commands and characters.
  1497. One solution is to use the "Sbox" environment:
  1498. \begin{example}
  1499.   \begin{Sbox}
  1500.   \begin{minipage}{5cm}
  1501.   \begin{verbatim}
  1502.   \My \Program \Listing
  1503.   if { foo } { bar } fi
  1504.   \end{verbatim}
  1505.   \end{minipage}
  1506.   \end{Sbox}
  1507.   \setlength{\fboxsep}{8pt}
  1508.   \fbox{\TheSbox}
  1509. \end{example}
  1510. "fancybox.sty" also contains a command that ``fixes'' \LaTeX's LR-box commands
  1511. for use with verbatim text:
  1512. \begin{LVerbatim}
  1513.   \VerbBox{<cmd>}{<LR stuff>}
  1514. \end{LVerbatim}
  1515. This is like
  1516. \begin{LVerbatim}
  1517.   <cmd>{<LR stuff>}
  1518. \end{LVerbatim}
  1519. but <LR stuff> can contain verbatim text.\footnote{Or other tricks that
  1520. involve "\catcode" changes, as occurs with some foreign language macros.} For
  1521. example:
  1522. \begin{example}
  1523.   \VerbBox{\fbox}{\verb+\foo{bar}+}
  1524. \end{example}
  1525. For footnotes, put the command "\VerbatimFootnotes" in the preamble, and then
  1526. you can use verbatim commands or environments in the argument of "\footnote".
  1527. This is an optional feature because it might conflict with somebody else's
  1528. modification of the footnote system.
  1529. If you try to define your own framed verbatim environment with
  1530. \begin{LVerbatim}
  1531.   \newenvironment{FramedVerb}%
  1532.     {\begin{Sbox}\begin{minipage}{5in}\begin{verbatim}}
  1533.     {\end{verbatim}\end{minipage}\end{Sbox}
  1534.       \setlength{\fboxsep}{8pt}\fbox{\TheSbox}}
  1535. \end{LVerbatim}
  1536. and then type
  1537. \begin{LVerbatim}
  1538.   \begin{FramedVerb}
  1539.     if { foo } { bar } fi
  1540.   \end{FramedVerb}
  1541. \end{LVerbatim}
  1542. you will again run into trouble because after the "\begin{verbatim}", \LaTeX\
  1543. is searching for the literal string "\end{verbatim}" as the end of the
  1544. verbatim text. It just skips right over the "\end{FramedVerb}" and may well
  1545. continue to the end of the file or until it throws up.
  1546. "fancybox.sty" contains some verbatim environments that get around this
  1547. problem and that have other advantages for LR-boxing verbatim listings, when
  1548. compared to the standard \LaTeX\ "verbatim" environment. Admittedly, many of
  1549. their special features have nothing to do with boxes.
  1550. Here are the basic verbatim environments:
  1551. \begin{description}
  1552.   \vitem"Verbatim" Works pretty much like \LaTeX's "verbatim".
  1553.   \vitem"LVerbatim" Like "Verbatim", but "list" rather than "trivlist" is used
  1554. to display the listing, and so it is indented from the left margin. (This is
  1555. what I am using for verbatim listings in this document.)
  1556.   \vitem"BVerbatim[<pos>]" Produces a box with the same width as the longest
  1557. verbatim line. The baseline is in the center, unless you include the optional
  1558. argument "[t]" for alignment with the top line or "[b]" for alignment with the
  1559. bottom line.
  1560.   \vitem"VerbatimOut{<file>}" Writes the verbatim text to <file>.
  1561.   \vitem"SaveVerbatim{<cmd>}" Saves the verbatim text as <cmd>. <cmd> is
  1562. defined globally, without checking whether <cmd> is already defined. Use
  1563. obviously innocuous names like "\MyTemp".
  1564. \end{description}
  1565. {\bf Important:} For any of these verbatim environments, or new verbatim
  1566. environments you define yourself (see below), nothing should come after
  1567. "\begin{Verbatim}" or before "\end{Verbatim}" on the same line --- not even
  1568. spaces!%
  1569.   \footnote{If you need to allow something to come before "\end{Verbatim}",
  1570. then you have two options:
  1571.   \begin{itemize}
  1572.   \item Put the command "\AltGetVerbatim" in the preamble. This switches to a
  1573. scheme where anything preceding "\end{Verbatim}" is simply ignored. This can
  1574. cause problems if you do really weird things with active characters or other
  1575. commands within the verbatim environment (e.g., active conditionals that are
  1576. not balanced within a line of verbatim text), but in this case you are
  1577. probably a good enough hacker to use the next option.
  1578.   \item "\EndVerbatimTokens" is a token register that you can set to the
  1579. tokens that should precede "\end{Verbatim}" on the same line, with their
  1580. verbatim "\catcode"'s.
  1581.   \end{itemize}}
  1582. If you put something after "\begin{Verbatim}" on the same line, it is simply
  1583. ignored. However, if you put something after "\end{Verbatim}" on the same
  1584. line, or if you misspell "\end{Verbatim}", you will get an error such as
  1585. \begin{LVerbatim}
  1586.   ! File ended while scanning use of \Verbatim.
  1587. \end{LVerbatim}
  1588. and the document will end at that point.
  1589. You can define new verbatim environments using "\newenvironment". You just
  1590. have to start the definition with
  1591. \begin{LVerbatim}
  1592.   \VerbatimEnvironment
  1593. \end{LVerbatim}
  1594.  For example, here is the framed verbatim environment we tried earlier:
  1595. \begin{example**}
  1596.   \newenvironment{FramedVerb}%
  1597.     {\VerbatimEnvironment
  1598.       \begin{Sbox}\begin{minipage}{5cm}\begin{Verbatim}}%
  1599.     {\end{Verbatim}\end{minipage}\end{Sbox}
  1600.       \setlength{\fboxsep}{8pt}\fbox{\TheSbox}}
  1601. \end{example**}
  1602. Let's give it a try:
  1603. \begin{example}
  1604.   \begin{FramedVerb}
  1605.   if { foo } { bar } fi
  1606.   \end{FramedVerb}
  1607. \end{example}
  1608. Here are three commands for inputting a whole file verbatim. The file must end
  1609. with a new line.
  1610. \begin{description}
  1611.   \vitem"\VerbatimInput{<file>}" Like "\Verbatim".
  1612.   \vitem"\LVerbatimInput{<file>}" Like "\LVerbatim".
  1613.   \vitem"\BVerbatimInput[<pos>]{<file>}" Like "\BVerbatim".
  1614. \end{description}
  1615. Here are three commands for making use of verbatim text that has been saved to
  1616. a command:
  1617. \begin{description}
  1618.   \vitem"\UseVerbatim{<cmd>}" Like "\Verbatim".
  1619.   \vitem"\LUseVerbatim{<cmd>}" Like "\LVerbatim".
  1620.   \vitem"\BUseVerbatim[<pos>]{<cmd>}" Like "\BVerbatim".
  1621. \end{description}
  1622. The "SaveVerbatim" environment and the "\UseVerbatim" commands are useful for 
  1623. including verbatim text in the argument of "\marginpar", "\fbox" and other
  1624. commands. For example, here is another way to define the "FramedVerb"
  1625. environment:
  1626. \begin{LVerbatim}
  1627.   \newenvironment{FramedVerb}%
  1628.     {\VerbatimEnvironment
  1629.       \begin{SaveVerbatim}{\MyTemp}}%
  1630.     {\end{SaveVerbatim}%
  1631.       \setlength{\fboxsep}{8pt}%
  1632.       \fbox{\begin{minipage}{5cm}\UseVerbatim{\MyTemp}
  1633.         \end{minipage}}}
  1634. \end{LVerbatim}
  1635. Here are some verbatim commands for short-pieces of (in-line) verbatim text:
  1636. \begin{description}
  1637.   \vitem"\Verb<char> <literal> <char>" \ \\
  1638.   Like \LaTeX's "\verb" command, but it will complain if it encounters a new
  1639. line in <literal>.\footnote{Be careful that your word processing does not
  1640. insert one for you.} For example:
  1641. \begin{example*}
  1642.   "\begin{quote}
  1643.   The main use for the \Verb+SaveVerbatim+
  1644.   environment and the \Verb+\UseVerbatim+
  1645.   commands is to include $\ldots$
  1646.   "\end{quote}
  1647. \end{example*}
  1648.   \vitem"\UseVerb{<cmd>}" Like "\UseVerbatim", but without any particular
  1649. formatting. It is intended for including short pieces of literal text saved
  1650. with "\SaveVerb" (below).\footnote{But it can also be used for multiple lines
  1651. saved with the "SaveVerbatim" environment if you want to do the formatting
  1652. yourself. E.g., try this in a tabbing environment with "\VerbatimTab"
  1653. appropriately defined.}
  1654.   \vitem"\SaveVerb[<whatever>]{<cmd>}<char> <literal> <char>"\ \\
  1655.   This is like "\Verb", but it saves <literal> as <cmd>, and then returns to
  1656. the optional argument <whatever>. Like the "SaveVerbatim" environment, it
  1657. defines <cmd> globally without checking whether <cmd> is already defined.
  1658. Without the optional argument, the most common use is for including verbatim
  1659. text in a "\marginpar", "\section" or other command argument.
  1660.   The optional argument can be used for special tricks. For example, all the
  1661. listings of commands in this documentation use "\vitem" in a "description"
  1662. environment, where "\vitem" is defined by:\footnote{The braces enclosing the
  1663. optional argument of "\SaveVerb" prevent the "]" inside the argument from
  1664. being mistaken for the end of the argument.}
  1665. \begin{LVerbatim}
  1666.   \newcommand{\vitem}%
  1667.     {\SaveVerb[{\item[\UseVerb{\MyTemp}]}]{\MyTemp}}
  1668. \end{LVerbatim}
  1669. Whereas
  1670. \begin{LVerbatim}
  1671.   \item[\Verb"\foo"]
  1672. \end{LVerbatim}
  1673. would not work because after "\item" reads its argument it is too late to
  1674. interpret "\foo" literally,
  1675. \begin{LVerbatim}
  1676.   \vitem"foo"
  1677. \end{LVerbatim}
  1678. does work because it is equivalent to
  1679. \begin{LVerbatim}
  1680.   \SaveVerb{\MyTemp}"foo"\item[\UseVerb{\MyTemp}]
  1681. \end{LVerbatim}
  1682. \end{description}
  1683. These environments and commands use various parameters that make it easy to
  1684. customize their behavior. However, until you want to find the need for such
  1685. customization, you might as well ignore the rest of this section.
  1686. Internally, "fancybox.sty" separates the reading and formatting of verbatim
  1687. text. Most of the environments and commands perform both functions, but
  1688. "SaveVerbatim" and "\SaveVerb" only read the text, while "UseVerbatim" (and
  1689. company) and "\UseVerb" only format the text. "VerbatimOut" gets special
  1690. treatment. The parameters that apply to each class of verbatim environment or
  1691. command is listed in Table \ref{verbtable}.
  1692. \begin{table}
  1693. \begin{center}
  1694. \renewcommand{\arraystretch}{0}
  1695. \setlength{\tabcolsep}{7pt}
  1696. \newcommand{\vs}{& \\[\tabcolsep]}
  1697. \newcommand{\VS}{\\ \vs \hline \vs}
  1698. \begin{tabular}{|l|l|}
  1699. \hline \vs
  1700. {\em Where} & {\em What}
  1701. \\ \vs \hline
  1702. \hline \vs
  1703.   \begin{Bflushleft}
  1704.     Environments\\
  1705.     that format
  1706.   \end{Bflushleft}
  1707.   \begin{Bflushleft}
  1708.     "\VerbatimSpace"\\
  1709.     "\VerbatimTab"\\
  1710.     "\VerbatimFont"\\
  1711.     "\VerbatimFuzz"\\
  1712.     "\EveryVerbatimLine"\\
  1713.     "\EveryVerbatim"\\
  1714.     "\ThisVerb"
  1715.   \end{Bflushleft}
  1716.   \begin{Bflushleft}
  1717.     Environments\\
  1718.     that read
  1719.   \end{Bflushleft}
  1720.   \begin{Bflushleft}
  1721.     "\EveryVerbatimCodes"\\
  1722.     "\ThisVerbCodes"
  1723.   \end{Bflushleft}
  1724.   \begin{Bflushleft}
  1725.     "\Verb" and\\
  1726.     "\UseVerb"
  1727.   \end{Bflushleft}
  1728.   \begin{Bflushleft}
  1729.     "\VerbSpace"\\
  1730.     "\VerbTab"\\
  1731.     "\VerbFont"\\
  1732.     "\EveryVerb"\\
  1733.     "\ThisVerb"
  1734.   \end{Bflushleft}
  1735.   \begin{Bflushleft}
  1736.     "\Verb" and\\
  1737.     "\SaveVerb"
  1738.   \end{Bflushleft}
  1739.   \begin{Bflushleft}
  1740.     "\EveryVerbCodes"\\
  1741.     "\ThisVerbCodes"
  1742.   \end{Bflushleft}
  1743.   \begin{Bflushleft}
  1744.     "VerbatimOut"
  1745.   \end{Bflushleft}
  1746.   \begin{Bflushleft}
  1747.     "\EveryVerbOutCodes"\\
  1748.     "\ThisVerbCodes"\\
  1749.     "\EveryVerbOutLine"\\
  1750.     "\ThisVerb"
  1751.   \end{Bflushleft}
  1752. \\ \vs \hline
  1753. \end{tabular}
  1754. \caption{Parameters for the verbatim environments and
  1755. commands.\label{verbtable}}
  1756. \end{center}
  1757. \end{table}
  1758. All the parameters, including "\VerbatimFuzz", are ordinary commands, and
  1759. should be changed with "\renewcommand".
  1760. Here is a description of each of the parameters for environments that format
  1761. the verbatim text:
  1762. \begin{description}
  1763.   \vitem"\VerbatimSpace" The insertion text for spaces. The default is "\ ",
  1764. which produces a blank space. Change it to "\ttspace" to get \ttspace.
  1765.   \vitem"\VerbatimTab" The insertion text for tabs. The default is
  1766. \begin{LVerbatim}
  1767.   \ \ \ \ \ \ \ \
  1768. \end{LVerbatim}
  1769.   \vitem"\VerbatimFont" The font to use for verbatim text. The default is
  1770. "\tt"
  1771.   \vitem"\VerbatimFuzz" This is the amount by which lines can be too long in a
  1772. "Verbatim" or "LVerbatim" environment before you get overfull "\hbox"
  1773. warnings. This threshold is usually .1pt, but the default definition of
  1774. "\VerbatimFuzz" is "2pt" because verbatim lines won't break and are therefore
  1775. often too long.
  1776.   \vitem"\EveryVerbatimLine" This is inserted at the beginning of each line of
  1777. verbatim environments or verbatim files. By default it does nothing. I like to
  1778. indent each line in the verbatim environment in the input file by 2 spaces, so
  1779. I define
  1780. \begin{LVerbatim}
  1781.   \renewcommand{\EveryVerbatimLine}[2]{}
  1782. \end{LVerbatim}
  1783. to eat those spaces. (But I have to remember to put in two spaces or space
  1784. markers for blank lines too.) You might also use it to number the lines. For
  1785. example:
  1786. \begin{example}
  1787.   \newcounter{VerbLineNo}
  1788.   \renewcommand{\EveryVerbatimLine}%
  1789.     {\makebox[10pt][r]{%
  1790.        \stepcounter{VerbLineNo}%
  1791.        \tiny\rm\arabic{VerbLineNo}}%
  1792.     \hspace{10pt}}
  1793.   \renewcommand{\EveryVerbatim}%
  1794.     {\setcounter{VerbLineNo}{0}}
  1795.   \begin{SaveVerbatim}{\MyTemp}
  1796.   \setlength{\fboxsep}{15pt}
  1797.   \setlength{\mylength}{\linewidth}
  1798.   \end{SaveVerbatim}
  1799.   \fbox{\BUseVerbatim{\MyTemp}}
  1800. \end{example}
  1801.   \vitem"\EveryVerbatim" Whatever else you want to say before formatting the
  1802. verbatim text. By default, it does nothing.
  1803.   \vitem"\ThisVerb" This is executed before any of the commands above, and
  1804. then its value is cleared. Use this to customize a single verbatim formatting
  1805. environment.
  1806. \end{description}
  1807. Here is a description of the parameters for environments that read the
  1808. verbatim text:
  1809. \begin{description}
  1810.   \vitem"\EveryVerbatimCodes" This command is inserted just before reading the
  1811. verbatim text. Use it to play with "\catcode"'s (see the {\em \TeX book}). For
  1812. example, I might type
  1813. \begin{LVerbatim}
  1814.   \renewcommand{\EveryVerbatimCodes}{\catcode`\"=14}
  1815. \end{LVerbatim}
  1816. if I want to use \Verb+"+ as a comment character in verbatim text.%
  1817. %% The use of SaveVerbatim and \SaveVerb is not necessary here because
  1818. %% \VerbatimFootnotes is in effect. This is just a test.
  1819. \begin{SaveVerbatim}{\MyTemp}
  1820.   \def\MyQuote{"}    % \MyQuote is now the character ",
  1821.   \def\temp{\Verb"}  %    in case I need it.
  1822.   \catcode`\"=13     % Now " is like a command.
  1823.   \let"\temp         % Now "foo" is like \Verb"foo"
  1824.   \def\do{\noexpand\do\noexpand}      % Now " can be used in verbatim
  1825.   \edef\dospecials{\dospecials\do\"}  % environments anyway.
  1826. \end{SaveVerbatim}\SaveVerb{\Foo}+"+\SaveVerb{\FFoo}+\Verb"foo"+%
  1827. \footnote{Here is another "\catcode" trick. We make \UseVerb{\Foo} a short
  1828. verbatim command, so that we can say \UseVerb{\Foo foo\Foo} instead of
  1829. \UseVerb{\FFoo}:
  1830. \LUseVerbatim{\MyTemp}}
  1831.   \vitem"\ThisVerbCodes" This command is executed before "\EveryVerbCodes",
  1832. and then it is cleared. Use this to fool with the "\catcode"`s of a single
  1833. verbatim environment.
  1834. \end{description}
  1835. The parameters for "\Verb", "\UseVerb" and "\SaveVerb" and the "VerbatimOut"
  1836. environment are analogous to the similar commands for other environments.
  1837. Here is an example of the use of "\ThisVerb" to define a variant of "\Verb"
  1838. that uses \ttspace\ to mark spaces:
  1839. \begin{LVerbatim}
  1840.   \newcommand{\SVerb}{%
  1841.     \renewcommand{\ThisVerb}%
  1842.       {\renewcommand{\VerbatimSpace}{\ttspace}}%
  1843.     \Verb}
  1844. \end{LVerbatim}
  1845. Finally, without further comment, here are the definitions of the "example"
  1846. and "example*" environments that were used for the examples in this document:
  1847. {\renewcommand{\EveryVerbatimLine}{}\LVerbatimInput{\jobname.ex1}}
  1848. \section{Changes}
  1849. \raggedright
  1850. \paragraph*{Version 0.9, November 23, 1992} First release.
  1851. \paragraph*{Version 0.91, November 25, 1992}
  1852. \begin{enumerate}
  1853.   \item "\shadowsize" is now a length, to be set with "\setlength" or
  1854. "\addtolength".
  1855.   \item "\fancypage" split into "\fancypage" and "\fancyput"
  1856. \end{enumerate}
  1857. \paragraph*{Version 0.92, December 20, 1992}
  1858. \begin{enumerate}
  1859.   \item New "\boxput" command for superimposing boxes.
  1860.   \item New "\VerbatimFootnotes" command.
  1861.   \item New "\VerbBox" command for verbatim boxes.
  1862.   \item New "Sbox" environment. Makes "\beginsbox" and "\endsbox"
  1863.     obsolete, but the latter have been retained for compatibility.
  1864. \end{enumerate}
  1865. \paragraph{Version 0.93, January 20, 1993}
  1866. \begin{enumerate}
  1867.   \item New "\EndVerbatimTokens" for tokens that precede "\end{Verbatim}".
  1868.   \item New "\AltGetVerbatim", to allow any tokens to precede
  1869. "\end{Verbatim}".
  1870.   \item Fixed bug in "\BVerbatimInput" that caused second line to be repeated.
  1871.   \item New "LandScape" environment, for rotating pages without rotating
  1872. headers and footers.
  1873.   \item Slide frames "Oval", "oval", "shadow" and "double" are defined when
  1874. "seminar.sty" v0.93 (and maybe later) is loaded.
  1875. \end{enumerate}
  1876. \paragraph{Version 1.0, February 10, 1993}
  1877. \begin{enumerate}
  1878.   \item Fixed bugs in "\boxput".
  1879.   \item New "Beqnarray" environment.
  1880. \end{enumerate}
  1881. \end{document}
  1882. %% END fancybox.doc
  1883.